package cn.codelab.springcloudalibaba.study.step03.controller;

import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


@RestController
@RequestMapping("/demo")
@AllArgsConstructor
public class ConsumerDemoController {

    private final RestTemplate restTemplate;

    @RequestMapping("/say")
    public String say(){
        // 使用RestTemplate调用服务
        String msg = restTemplate.getForObject("http://service-provider/demo/hello?msg=Nacos", String.class);
        return msg;
    }
}
